package com.csxh.jdbc;

import static org.junit.Assert.*;

import java.sql.Connection;
import java.util.List;

import org.junit.Assert;
import org.junit.Test;

public class JdbcUtilTest {

	@Test
	public void testOpenConnertion() {
		Connection conn=JdbcUtil.openConnertion();
		Assert.assertTrue(conn!=null);
		JdbcUtil.closeConnertion();
	}

	@Test
	public void testExcute() {
		String sql="INSERT INTO `aa`(`name`,`age`)VALUES('saass','123')";
		boolean b=JdbcUtil.excute(sql);
	}
	@Test
	public void testFind() {
		String sql="SELECT * FROM `aa`";
		List<Object[]>list=JdbcUtil.find(sql);
		Assert.assertTrue(list.size()>0);
	}
	@Test
	public void testAdd() {
		String sql="INSERT INTO `aa`(`name`,`age`)VALUES('sof','12355')";
		boolean b=JdbcUtil.add(sql);
		Assert.assertTrue(b);
	}
	@Test
	public void testDelete() {
		String sql="DELETE FROM`aa`WHERE `id`=4";
		boolean b=JdbcUtil.delete(sql);
		Assert.assertTrue(b);
	}
	@Test
	public void testUpdate() {
		String sql="UPDATE `aa` SET `name`='qaz',`age`='52' WHERE `id`=1";
		boolean b=JdbcUtil.update(sql);
		Assert.assertTrue(b);
	}
}
